#pragma once

#include <iostream>
#include <string>
#include <ctime>

std::string opers = "+-*/%";

enum{
    DivZero = 1,
    ModZero,
    UnKnown
};

class Task
{
public:
    Task(int data1, int data2, char op)
        : _data1(data1), _data2(data2), _oper(op), _result(0), _exitcode(0)
    {
    }

    void operator()()
    {
        run();
    }

    void run()
    {
        switch (_oper)
        {
        case '+':
            _result = _data1 + _data2;
            break;
        case '-':
            _result = _data1 - _data2;
            break;
        case '*':
            _result = _data1 * _data2;
            break;
        case '/':
            {
                if(_data2 == 0) _exitcode = DivZero;
                else _result = _data1 / _data2;
            }
            break;
        case '%':
            {
                if(_data2 == 0) _exitcode = ModZero;
                else _result = _data1 % _data2;
            }
            break;
        default:
            _exitcode = UnKnown;
            break;
        }
    }
    std::string GetResult()
    {
        std::string r = std::to_string(_data1);
        r += _oper;
        r += std::to_string(_data2);
        r += "=";
        r += std::to_string(_result);
        r += "[";
        r += std::to_string(_exitcode);
        r += "]";

        return r;
    }

    std::string GetTask()
    {
        std::string r = std::to_string(_data1);
        r += _oper;
        r += std::to_string(_data2);
        r += "=?";

        return r;
    }

    ~Task()
    {
    }

private:
    int _data1;
    int _data2;
    char _oper;

    int _result;
    int _exitcode;
};